from pymongo import MongoClient
import pymongo
import os
import inference
import numpy as np
import csv
client = MongoClient(port=27017)
db=client['tiktok']
i=0
obj={
    '_id':'',
    'text_feature':{
        'text':'',
        'stickerText':[],
    },
    'video_feature':{
        'text_embed':[],
        'img_embed':{},
        'audio':{
            'yamnet':[]
        },
        'editing':{},
        'label':{},
        'residual':{}
    },
    'img_feature':{

    }
}
with open('E:\\data_pi\\top100list.tsv','r', encoding='utf-8',newline='\n') as fin:
    reader = csv.reader(fin, delimiter='\t')
    for line in reader:
        col = line[0]
        k = line[1]

        item=db[col].find_one({'_id':k})
        if os.path.exists('E:\\Tiktok\\Hashtag\\' + col + '\\' + id + '.mp4') and item is None:
            temp=obj
            temp['_id']=k
            db[col].insert_one(temp)
